package com.homework.Pets;

import com.day0922.json.Dog;

public class Master {
    public Pets getPet(String type){
        if (type.equals("Dogs")){
            Dogs dogs = new Dogs("花花",2,100,100,"二哈");
            return dogs;
        }
        else if (type.equals("Cats")){
            Cats cats = new Cats("猫猫",1,100,100,"喝奶");
            return cats;
        }
        else if (type.equals("Penguins")){
            Penguins penguins = new Penguins("草草",3,100,100,"女");
            return penguins;
        }
        return null;
    }

    public void feet(Pets pets){
        pets.eat();
    }
    public void cure(Pets pets){
        pets.toHospital();
    }
    public void plays(Pets pets){
        if (pets instanceof Dogs){
            Dogs dogs = (Dogs)pets;
            dogs.play();
        }
        else if (pets instanceof Cats){
            Cats cats = (Cats) pets;
            cats.play();
        }
        else if (pets instanceof Cats){
            Penguins penguins = (Penguins)pets;
            penguins.play();
        }
    }
}
